<?php
namespace Newadmin\Controller\Common;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){
        
        /*
         * 这里判断访问的session权限
         * 
         */
        
    }
    
    public function dashboard() {
        $this->display();
    }
    
    
    /*
     * 登录页面
     */
    public function login() {
        if(IS_POST)
        {
            $account = I("post.account");
            $password = I("post.password");
            
            $map['username'] = $account;
            $map['password']=md5($password);
            
            $res = M("admin")->where($map)->find();
            
            if(!empty($res))
            {
                session("admin",$account);
                redirect(U("Newadmin/Widget/Vote/topics"));
                
            }
            else
            {
                $this->error("帐号密码有误");
            }
        }
        else
        {
            $this->display();
        }
    }
}